<template>
	<view>
		<view-grid ref="grid" :index="true" :options="options">
			<!-- 自定义slot -->
			<view @click="viewClick" slot="gridHeader" class="grid-header">
				{{ gridHeaderText }}
			</view>
		</view-grid>
	</view>
</template>

<script>
//************************************************
//  *Author：jxx
//  *QQ：283591387
//  *自定义业务逻辑扩展
//************************************************
import extend from './q_after_recycleExtend.js';
import options from './q_after_recycleOptions.js';
import detailOptions from '../q_after_recycleList/q_after_recycleListOptions.js';
export default {
	data() {
		let _options = options();
		_options.extend = extend;
		_options.detailOptions = detailOptions();
		return {
			gridHeaderText: '', //随便输入字符后可以显示出来
			options: _options,
			time: null
		};
	},
	onShow() {
		let pages = getCurrentPages();
		// console.log('pages', pages);
		let prevPage = pages[pages.length - 2];
		this.time = setInterval(() => {
			console.log('定时器');
			if (this.$refs.grid) {
				clearInterval(this.time);
				if (this.$refs.grid.fabButtons) {
					this.$refs.grid.fabButtons.forEach((item) => {
						if (item.name == '添加') {
							item.onClick = () => {
								const optionsObj = {
									editFormOptions: this.options.editFormOptions,
									detailColumns: this.options.detailOptions.columns,
									detailtable: this.options.table
								};
								uni.setStorageSync('optionsObj', JSON.stringify(optionsObj));
								uni.navigateTo({
									url: '/pages/addPage/addPage?biaoming=q_after_recycle&&currentAction=Add&&ID=After_recycle&&zibiaoming=q_after_recycle_not'
								});
							};
						}
					});
				}
				this.$refs.grid.refresh(); //刷新
			}
		}, 500);
	},
	methods: {
		viewClick() {
			//获取生成页面grid的对象
			console.log(this.$refs.grid.searchFormFields);
		}
	}
};
</script>

<style></style>
